package com.example.administrator.testdagger.tview;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

/**
 * Description: 
 * ModelName:
 *
 * @author WangJQ
 *Create at:  2018/6/6 11:19
 * Company: 沈阳艾尔时代科技发展有限公司
 * Copyright: (c)2018 AIR Times Inc. All rights reserved.
 * @version 1.0
 */

public class CustomProgress extends View {

    private static final String TAG = "CustomProgress";

    private Paint mPaint;
    private float mWidth;
    private float mHeight;

    public CustomProgress(Context context) {
        this(context, null);
    }

    public CustomProgress(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public CustomProgress(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init();
    }

    private void init() {
        mPaint = new Paint();
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        Log.d(TAG, "onMeasure");
        mWidth = MeasureSpec.getSize(widthMeasureSpec);
        mHeight = MeasureSpec.getSize(heightMeasureSpec);
        Log.d(TAG, "onMeasure: height is: " + mHeight + "width is: " + mHeight);
    }

    @Override
    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
        super.onSizeChanged(w, h, oldw, oldh);
        Log.d(TAG, "onSizeChanged");
        Log.d(TAG, "onSizeChanged: height is: " + h + "width is: " + w);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        mPaint.setColor(Color.DKGRAY);
        canvas.drawRect(0, 0, mWidth, mHeight, mPaint);
    }
}
